/*
 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

/*
 * @(#)DataSourceConnection.java	1.14 02/01/12
 */

package jdbcts.common;

import com.sun.cts.util.*;
import com.sun.cts.harness.*;
import com.sun.cts.porting.*;

import java.sql.*;
import javax.sql.*;
import java.util.*;

public class DataSourceConnection extends ServiceEETest
implements JDBCTestConnectionManager{

  public Connection getConnection(Properties p) throws ClassNotFoundException, SQLException, Exception{
    CTSNamingContextInterface jc = null;
    DataSource ds1 = null;
    Connection con = null;

    TestUtil.logTrace("Getting the initial context"); 
    jc = new CTSNamingContext();
    TestUtil.logTrace("jc: " + jc.toString());

    TestUtil.logTrace("Looking up the JNDI DataSource names");
    ds1 = (DataSource)jc.lookup("java:comp/env/jdbc/DB1");
    TestUtil.logTrace("ds1: " + ds1.toString());

    TestUtil.logTrace("Attempting to make the connection");
    con = ds1.getConnection();
    TestUtil.logTrace("Made the connection via DataSource!");

    return con;
  }

}
